package com.xh.audit.vo.webform;

import com.mybatisflex.core.query.QueryWrapper;
import com.xh.audit.entity.project.AuditEvidence;
import lombok.Data;
import lombok.EqualsAndHashCode;

import static com.xh.audit.entity.project.table.AuditEvidenceTableDef.AUDIT_EVIDENCE;
import static com.xh.audit.entity.project.table.ProjectTableDef.PROJECT;


@Data
@EqualsAndHashCode(callSuper = true)
public class AuditEvidenceQuery extends PageParams<AuditEvidence> {
    private String evidenceCode;
    private Integer projectId;
    private String projectName;
    private Integer evidenceType;

    public QueryWrapper queryWrapperBuild() {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .select(AUDIT_EVIDENCE.DEFAULT_COLUMNS, PROJECT.PROJECT_NAME)
                .from(AUDIT_EVIDENCE).innerJoin(PROJECT).on(AUDIT_EVIDENCE.PROJECT_ID.eq(PROJECT.ID))
                .and(AUDIT_EVIDENCE.EVIDENCE_CODE.eq(evidenceCode))
                .and(AUDIT_EVIDENCE.PROJECT_ID.eq(projectId))
                .and(AUDIT_EVIDENCE.EVIDENCE_TYPE.eq(evidenceType))
                .and(PROJECT.PROJECT_NAME.likeLeft(projectName));
        return queryWrapper;
    }
}
